<?php
namespace app\admin\controller;

use app\admin\controller\AdminBase;
use think\db;
class Feedback extends AdminBase
{

    public $user_id;

    public function _initialize()
    {
        parent::_initialize();
    }

    function list()
    {
        $msg = model('Msg');
        $all = $msg->count();
        $today = $msg->whereTime('create_time', 'today')->count();
        $week = $msg->whereTime('create_time', 'week')->count();
        $month = $msg->whereTime('create_time', 'month')->count();

        $number = 5;
        $top10 = Db::query("select * from ts_msg limit ".($all-$number).",".$all);
        $len = sizeof($top10);
        for($x=($number-1); $x>=0; $x--)
        {
            $top[$number-1-$x] = $top10[$x];
        }
        return view('',
        	[
        		'all' => $all,
        		'today' => $today,
        		'week' => $week,
        		'month' => $month,
                'top10' => $top,

        		]);
    }

	function all()
    {
    	$msg = model('Msg');
        $all = $msg->select();
        $len = sizeof($all);
        for($x=($len-1); $x>=0; $x--)
        {
            $top[$len-1-$x] = $all[$x];
        }
        return view('', ['all'=>$top]);
    }

    function today()
    {
    	$msg = model('Msg');
        $today = $msg->whereTime('create_time', 'today')->select();
        $len = sizeof($today);
        $top = [];
        for($x=($len-1); $x>=0; $x--)
        {
            $top[$len-1-$x] = $today[$x];
        }
        return view('', ['today'=>$top]);
    }

    function week()
    {
    	$msg = model('Msg');
        $week = $msg->whereTime('create_time', 'week')->select();
        $len = sizeof($week);
        $top = [];
        for($x=($len-1); $x>=0; $x--)
        {
            $top[$len-1-$x] = $week[$x];
        }
        return view('', ['week'=>$top]);
    }

    function month()
    {
    	$msg = model('Msg');
        $month = $msg->whereTime('create_time', 'month')->select();
        $len = sizeof($month);
        $top = [];
        for($x=($len-1); $x>=0; $x--)
        {
            $top[$len-1-$x] = $month[$x];
        }
        return view('', ['month'=>$top]);
    }

}
